/*
 * compiler/compiler.hh - Unifying definitions for compiler-specific things.
 * Copyright (C) 2007  Mikhail Vorozhtsov
 * See the LICENSE section of the README file for details.
 */

/* $Id$ */

#ifndef HEADER_LIBCOMPILER_COMPILER_COMPILER_HH
#define HEADER_LIBCOMPILER_COMPILER_COMPILER_HH

#ifdef __GNUC__
# define PACKED __attribute__((packed))
# define UNUSED __attribute__((unused))
# define USED __attribute__((used))
# define SECTION(x) __attribute__((section(x)))
# define ALIGNED(x) __attribute__((aligned(x)))
# define INLINE inline __attribute__((always_inline))
# define offsetof __builtin_offsetof
# define va_list __builtin_va_list
# define va_start __builtin_va_start
# define va_arg __builtin_va_arg
# define va_end __builtin_va_end
#else /* !__GNUC__ */
# error Unsupported compiler
#endif /* __GNUC__ */

#define SIZE(ARRAY) (sizeof (ARRAY) / sizeof ((ARRAY)[0]))

#define NULL 0

template <typename T>
INLINE
void *
operator new (typeof (sizeof (T)) size UNUSED, T *t)
{
  return t;
}

#endif /* HEADER_LIBCOMPILER_COMPILER_COMPILER_HH */

